﻿@model IEnumerable<HelloMinasan.Domain.QA>
@{
    ViewBag.Title = "Index";
}

@using (Html.BeginForm())
{
    <a style="float:right;font-size: 15px" href="@Url.Action("Create", "QA")">
    <div style="padding-left:40px;">
        <span class="titleNewFont" style="font-size: 20px; font-weight: normal">Create QA</span>
        <hr />
    </div>
    </a>
    <form id="myForm">
        <input type="submit" value="All" name="submitButton" />
        <input type="submit" value="Vocabulary" name="submitButton" />
        <input type="submit" value="Grammar" name="submitButton" />
        <input type="submit" value="Request document" name="submitButton" />
        <input type="submit" value="Others" name="submitButton" />
    </form>

    <div class="contentSection">
        <table width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td valign="top" width="50%">
                    <div class="titleSection">
                        Title/Thread Starter
                    </div>
                </td>

                <td valign="top">
                    <div class="titleSection">
                        Replies/Views
                    </div>
                </td>

                <td valign="top">
                    <div class="titleSection">
                        Last Post By
                    </div>
                </td>
            </tr>

            @foreach (var item in Model)
            {
                string Ownerslast;
                string Datelast;
                
                if (item.QAComments.Count > 0)
                {
                    Ownerslast = item.QAComments.Last().User.Username;
                    Datelast = item.QAComments.Last().PostedDate.ToString();
                }
                else
                {
                    Ownerslast = "No Data";
                    Datelast = "No Data";
                }
                
                <tr>
                    @*Phần tiểu đề *@
                    <td>
                        <div class="contentSectionInside norightborder">
                            <a href="Details/@item.Id" title ="@item.QuestionContent">
                                <strong>[@item.QuestionCatagory]@item.QuestionTitle</strong>
                            </a><br />
                            <a class="titleNewFont" title ="@item.User.DisplayName" href="/Account/UserInformation/@item.User.Id">
                                Started by: <b> @item.User.Id</b>, @item.PostedDate</a>
                        <div>
                    </td>
                     @*trả lời/ view *@
                    <td>
                        <div class="contentSectionInside norightborder">
                            <a>
                                Replies: @item.SumAnsert
                            </a><br />
                            <a>
                                Views: @item.SumView
                            </a>
                        </div>
                    </td>

                    <td>
                        <div class="contentSectionInside norightborder">
                            <a class="titleNewFont" href="/Account/UserInformation/@Ownerslast"><b> @Ownerslast</b></a>
                            <br />
                            <a>
                               @Datelast
                            </a>
                        </div>
                    </td>
                </tr>
            }
        </table>
    </div>
}


<div>
    <table width="100%" class="contentSection">
        <tr>
            <td class="contentSectionInside">
                @{Html.RenderAction("ShowQaTopNew");}
            </td>
            <td class="contentSectionInside">
                @{Html.RenderAction("ShowQaTopAnsert");}
            </td>
        </tr>
    </table>
</div>
